package com.zjdiepu.www.proxy.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.diepu.www.client.proxy.partner.request.own.DiepuZxCopyApplyRequest;
import com.diepu.www.client.proxy.partner.request.own.DiepuZxQuerySuccessBusiIdUpRequest;
import com.zjdiepu.www.config.ClientConfig;
import com.zjdiepu.www.consts.ProxyService;
import com.zjdiepu.www.net.HttpClient;
import com.zjdiepu.www.proxy.OwnDiepuService;
import com.zjdiepu.www.response.BooleanResponse;
import com.zjdiepu.www.security.base.enums.ResultCode;
import com.zjdiepu.www.security.client.encode.BaseEncryptService;
import com.zjdiepu.www.security.exception.BasePartnerException;
import com.zjdiepu.www.security.server.core.Partners;

@Service
public class OwnDiepuServiceImpl extends BaseEncryptService implements OwnDiepuService {

	//这是稻普调中间服务器
	
	@Override
	public BooleanResponse diepuZxCopyApply(DiepuZxCopyApplyRequest diepuZxCopyApplyRequest, Partners partner)throws BasePartnerException 
	{
		
		
		//签名
		String signEncrypt = signEncrypt(diepuZxCopyApplyRequest, partner);
		if(StringUtils.isBlank(signEncrypt)) 
		{
			throw new BasePartnerException(ResultCode.FAIL_PARAM_EMPTY);
		}
		String noticeStatus = HttpClient.postJson(ClientConfig.getPartnerGateWay(partner) + ProxyService.DIEPUZXCOPYAPPLY, signEncrypt);
		return valdateDencrypt(noticeStatus, BooleanResponse.class, partner);
	}

	@Override
	public BooleanResponse diepuZxQuerySuccessBusiIdUp(DiepuZxQuerySuccessBusiIdUpRequest diepuZxQuerySuccessBusiIdUpRequest,Partners partner) throws BasePartnerException
	{
		
		
		//签名
		String signEncrypt = signEncrypt(diepuZxQuerySuccessBusiIdUpRequest, partner);
		if(StringUtils.isBlank(signEncrypt)) 
		{
			throw new BasePartnerException(ResultCode.FAIL_PARAM_EMPTY);
		}
		String noticeStatus = HttpClient.postJson(ClientConfig.getPartnerGateWay(partner) + ProxyService.DIEPUZXQUERYSUCCESSBUSIIDUP, signEncrypt);
		return valdateDencrypt(noticeStatus, BooleanResponse.class, partner);
	}
	
}
